package com.cars.grpc;

import com.cars.grpc.customer.CustomerProto;
import com.cars.grpc.server.customer.repository.CustomerRepository;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import java.util.ArrayList;
import java.util.List;

@SpringBootApplication
public class ServerCustomerApp {

    public static void main(String[] args) {
        SpringApplication.run(ServerCustomerApp.class, args);
    }

    @Bean
    CustomerRepository repository() {
        List<CustomerProto.Customer> customers = new ArrayList<>();
        customers.add(CustomerProto.Customer.newBuilder().setId(1).setPesel("12345").setName("成龙")
                .setType(CustomerProto.Customer.CustomerType.INDIVIDUAL).build());
        customers.add(CustomerProto.Customer.newBuilder().setId(2).setPesel("12346").setName("李连杰")
                .setType(CustomerProto.Customer.CustomerType.INDIVIDUAL).build());
        customers.add(CustomerProto.Customer.newBuilder().setId(3).setPesel("12347").setName("甄子丹")
                .setType(CustomerProto.Customer.CustomerType.INDIVIDUAL).build());
        customers.add(CustomerProto.Customer.newBuilder().setId(4).setPesel("12348").setName("李小龙")
                .setType(CustomerProto.Customer.CustomerType.INDIVIDUAL).build());
        return new CustomerRepository(customers);
    }

}
